home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / MacTCP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  21.6 KB  |  741 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        MacTCP.h
  3.  
  4.      Contains:    TCP Manager Interfaces.
  5.  
  6.      Version:    Technology:    MacTCP 2.0.6
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1989-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __MACTCP__
  19. #define __MACTCP__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. #ifndef __APPLETALK__
  28. #include <AppleTalk.h>
  29. #endif
  30.  
  31.  
  32.  
  33. #if PRAGMA_ONCE
  34. #pragma once
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42. #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52.  
  53. /*
  54. Developer Notes:
  55.         0. This MacTCP header replaces what used to be defined in the following header files
  56.             MacTCPCommonTypes.h
  57.             GetMyIPAddr.h
  58.             MiscIPPB.h
  59.             TCPPB.h
  60.             UDPPB.h 
  61.             
  62.             When the various control calls are made to the ip driver, you must set up a 
  63.             NewRoutineDescriptor for every non-nil completion routine and/or notifyProc parameter.  
  64.             Otherwise, the 68K driver code, will not correctly call your routine.
  65.         1. For ipctlGetAddr Control calls, use NewGetIPIOCompletionProc
  66.             to set up a GetIPIOCompletionUPP universal procptr to pass as
  67.             the ioCompletion parameter.
  68.         2. For the ipctlEchoICMP and ipctlLAPStats Control calls, use 
  69.             NewIPIOCompletion to set up a IPIOCompletionUPP universal procptr
  70.             to pass in the ioCompletion field of the parameter block.
  71.         3. For TCPCreatePB Control calls, use NewTCPNotifyProc to set up a
  72.             TCPNotifyUPP universal procptr to pass in the notifyProc field
  73.             of the parameter block
  74.         4. For all of the TCP Control calls using the TCPiopb parameter block,
  75.             use NewTCPIOCompletionProc to set up a TCPIOCompletionUPP
  76.             universal procptr to pass in the ioCompletion field of the paramter
  77.             block.
  78.         5. For UDBCreatePB Control calls, use NewUDPNotifyProc to set up a
  79.             UDPNotifyUPP universal procptr to pass in the notifyProc field
  80.             of the parameter block
  81.         6. For all of the UDP Control calls using the UDPiopb parameter block,
  82.             use NewUDPIOCompletionProc to set up a UDPIOCompletionUPP
  83.             universal procptr to pass in the ioCompletion field of the paramter
  84.             block.
  85.         7. For all calls implementing a notifyProc or ioCompletion routine
  86.             which was set up using a NewTCPRoutineProc call, do not call
  87.             DisposeRoutineSDescriptor on the universal procptr until
  88.             after the completion or notify proc has completed.
  89. */
  90.  
  91. /* MacTCP return Codes in the range -23000 through -23049 */
  92.  
  93. enum {
  94.     inProgress                    = 1,                            /* I/O in progress */
  95.     ipBadLapErr                    = -23000,                        /* bad network configuration */
  96.     ipBadCnfgErr                = -23001,                        /* bad IP configuration error */
  97.     ipNoCnfgErr                    = -23002,                        /* missing IP or LAP configuration error */
  98.     ipLoadErr                    = -23003,                        /* error in MacTCP load */
  99.     ipBadAddr                    = -23004,                        /* error in getting address */
  100.     connectionClosing            = -23005,                        /* connection is closing */
  101.     invalidLength                = -23006,
  102.     connectionExists            = -23007,                        /* request conflicts with existing connection */
  103.     connectionDoesntExist        = -23008,                        /* connection does not exist */
  104.     insufficientResources        = -23009,                        /* insufficient resources to perform request */
  105.     invalidStreamPtr            = -23010,
  106.     streamAlreadyOpen            = -23011,
  107.     connectionTerminated        = -23012,
  108.     invalidBufPtr                = -23013,
  109.     invalidRDS                    = -23014,
  110.     invalidWDS                    = -23014,
  111.     openFailed                    = -23015,
  112.     commandTimeout                = -23016,
  113.     duplicateSocket                = -23017
  114. };
  115.  
  116. /* Error codes from internal IP functions */
  117.  
  118. enum {
  119.     ipDontFragErr                = -23032,                        /* Packet too large to send w/o fragmenting */
  120.     ipDestDeadErr                = -23033,                        /* destination not responding */
  121.     icmpEchoTimeoutErr            = -23035,                        /* ICMP echo timed-out */
  122.     ipNoFragMemErr                = -23036,                        /* no memory to send fragmented pkt */
  123.     ipRouteErr                    = -23037,                        /* can't route packet off-net */
  124.     nameSyntaxErr                = -23041,
  125.     cacheFault                    = -23042,
  126.     noResultProc                = -23043,
  127.     noNameServer                = -23044,
  128.     authNameErr                    = -23045,
  129.     noAnsErr                    = -23046,
  130.     dnrErr                        = -23047,
  131.     outOfMemory                    = -23048
  132. };
  133.  
  134.  
  135.  
  136. enum {
  137.     BYTES_16WORD                = 2,                            /* bytes per = 16, bit ip word */
  138.     BYTES_32WORD                = 4,                            /* bytes per = 32, bit ip word */
  139.     BYTES_64WORD                = 8                                /* bytes per = 64, bit ip word */
  140. };
  141.  
  142. /* 8-bit quantity */
  143. typedef UInt8                             b_8;
  144. /* 16-bit quantity */
  145. typedef UInt16                             b_16;
  146. /* 32-bit quantity */
  147. typedef UInt32                             b_32;
  148. /* IP address is 32-bits */
  149. typedef b_32                             ip_addr;
  150. struct ip_addrbytes {
  151.     union {
  152.         b_32                             addr;
  153.         UInt8                             byte[4];
  154.     }                                 a;
  155. };
  156. typedef struct ip_addrbytes ip_addrbytes;
  157.  
  158. struct wdsEntry {
  159.     unsigned short                     length;                        /* length of buffer */
  160.     Ptr                             ptr;                        /* pointer to buffer */
  161. };
  162. typedef struct wdsEntry wdsEntry;
  163.  
  164. struct rdsEntry {
  165.     unsigned short                     length;                        /* length of buffer */
  166.     Ptr                             ptr;                        /* pointer to buffer */
  167. };
  168. typedef struct rdsEntry rdsEntry;
  169.  
  170. typedef unsigned long                     BufferPtr;
  171. typedef unsigned long                     StreamPtr;
  172.  
  173. enum {
  174.     netUnreach                    = 0,
  175.     hostUnreach                    = 1,
  176.     protocolUnreach                = 2,
  177.     portUnreach                    = 3,
  178.     fragReqd                    = 4,
  179.     sourceRouteFailed            = 5,
  180.     timeExceeded                = 6,
  181.     parmProblem                    = 7,
  182.     missingOption                = 8,
  183.     lastICMPMsgType                = 32767
  184. };
  185.  
  186. typedef unsigned short                     ICMPMsgType;
  187. typedef b_16                             ip_port;
  188. struct ICMPReport {
  189.     StreamPtr                         streamPtr;
  190.     ip_addr                         localHost;
  191.     ip_port                         localPort;
  192.     ip_addr                         remoteHost;
  193.     ip_port                         remotePort;
  194.     short                             reportType;
  195.     unsigned short                     optionalAddlInfo;
  196.     unsigned long                     optionalAddlInfoPtr;
  197. };
  198. typedef struct ICMPReport ICMPReport;
  199.  
  200. /* csCode to get our IP address */
  201.  
  202. enum {
  203.     ipctlGetAddr                = 15
  204. };
  205.  
  206. typedef struct GetAddrParamBlock         GetAddrParamBlock;
  207. typedef CALLBACK_API_C( void , GetIPIOCompletionProcPtr )(GetAddrParamBlock *iopb);
  208. typedef STACK_UPP_TYPE(GetIPIOCompletionProcPtr)                 GetIPIOCompletionUPP;
  209. struct GetAddrParamBlock {
  210.     QElem *                            qLink;
  211.     short                             qType;
  212.     short                             ioTrap;
  213.     Ptr                             ioCmdAddr;
  214.     GetIPIOCompletionUPP             ioCompletion;
  215.     OSErr                             ioResult;
  216.     StringPtr                         ioNamePtr;
  217.     short                             ioVRefNum;
  218.     short                             ioCRefNum;
  219.     short                             csCode;
  220.     ip_addr                         ourAddress;                    /* our IP address */
  221.     long                             ourNetMask;                    /* our IP net mask */
  222. };
  223.  
  224. /* control codes */
  225.  
  226. enum {
  227.     ipctlEchoICMP                = 17,                            /* send icmp echo */
  228.     ipctlLAPStats                = 19                            /* get lap stats */
  229. };
  230.  
  231.  
  232. typedef struct ICMPParamBlock             ICMPParamBlock;
  233. typedef CALLBACK_API_C( void , IPIOCompletionProcPtr )(ICMPParamBlock *iopb);
  234. typedef STACK_UPP_TYPE(IPIOCompletionProcPtr)                     IPIOCompletionUPP;
  235. struct ICMPParamBlock {
  236.     QElem *                            qLink;
  237.     short                             qType;
  238.     short                             ioTrap;
  239.     Ptr                             ioCmdAddr;
  240.     IPIOCompletionUPP                 ioCompletion;
  241.     OSErr                             ioResult;
  242.     StringPtr                         ioNamePtr;
  243.     short                             ioVRefNum;
  244.     short                             ioCRefNum;
  245.     short                             csCode;
  246.     short                             params[11];
  247.     struct {
  248.         unsigned long                     echoRequestOut;            /* time in ticks of when the echo request went out */
  249.         unsigned long                     echoReplyIn;            /* time in ticks of when the reply was received */
  250.         rdsEntry                         echoedData;                /* data received in responce */
  251.         Ptr                             options;
  252.         unsigned long                     userDataPtr;
  253.     }                                 icmpEchoInfo;
  254. };
  255.  
  256. typedef CALLBACK_API_C( void , ICMPEchoNotifyProcPtr )(ICMPParamBlock *iopb);
  257. typedef STACK_UPP_TYPE(ICMPEchoNotifyProcPtr)                     ICMPEchoNotifyUPP;
  258. typedef struct LAPStats                 LAPStats;
  259. struct IPParamBlock {
  260.     QElem *                            qLink;
  261.     short                             qType;
  262.     short                             ioTrap;
  263.     Ptr                             ioCmdAddr;
  264.     IPIOCompletionUPP                 ioCompletion;
  265.     OSErr                             ioResult;
  266.     StringPtr                         ioNamePtr;
  267.     short                             ioVRefNum;
  268.     short                             ioCRefNum;
  269.     short                             csCode;
  270.     union {
  271.         struct {
  272.             ip_addr                         dest;                /* echo to IP address */
  273.             wdsEntry                         data;
  274.             short                             timeout;
  275.             Ptr                             options;
  276.             unsigned short                     optLength;
  277.             ICMPEchoNotifyUPP                 icmpCompletion;
  278.             unsigned long                     userDataPtr;
  279.         }                                 IPEchoPB;
  280.         struct {
  281.             LAPStats *                        lapStatsPtr;
  282.         }                                 LAPStatsPB;
  283.     }                                 csParam;
  284. };
  285. typedef struct IPParamBlock IPParamBlock;
  286.  
  287.  
  288. struct nbp_entry {
  289.     ip_addr                         ip_address;                    /* IP address */
  290.     AddrBlock                         at_address;                    /* matching AppleTalk address */
  291.     Boolean                         gateway;                    /* TRUE if entry for a gateway */
  292.     Boolean                         valid;                        /* TRUE if LAP address is valid */
  293.     Boolean                         probing;                    /* TRUE if NBP lookup pending */
  294.     SInt8                             afiller;                    /* Filler for proper byte alignment     */
  295.     long                             age;                        /* ticks since cache entry verified */
  296.     long                             access;                        /* ticks since last access */
  297.     SInt8                             filler[116];                /* for internal use only !!! */
  298. };
  299. typedef struct nbp_entry nbp_entry;
  300.  
  301. struct Enet_addr {
  302.     b_16                             en_hi;
  303.     b_32                             en_lo;
  304. };
  305. typedef struct Enet_addr Enet_addr;
  306.  
  307. struct arp_entry {
  308.     short                             age;                        /* cache aging field */
  309.     b_16                             protocol;                    /* Protocol type */
  310.     ip_addr                         ip_address;                    /* IP address */
  311.     Enet_addr                         en_address;                    /* matching Ethernet address */
  312. };
  313. typedef struct arp_entry arp_entry;
  314.  
  315. union LAPStatsAddrXlation {
  316.     arp_entry *                        arp_table;
  317.     nbp_entry *                        nbp_table;
  318. };
  319. typedef union LAPStatsAddrXlation LAPStatsAddrXlation;
  320.  
  321. struct LAPStats {
  322.     short                             ifType;
  323.     char *                            ifString;
  324.     short                             ifMaxMTU;
  325.     long                             ifSpeed;
  326.     short                             ifPhyAddrLength;
  327.     char *                            ifPhysicalAddress;
  328.     LAPStatsAddrXlation             AddrXlation;
  329.     short                             slotNumber;
  330. };
  331.  
  332. /* number of ARP table entries */
  333.  
  334. enum {
  335.     ARP_TABLE_SIZE                = 20
  336. };
  337.  
  338.  
  339. enum {
  340.     NBP_TABLE_SIZE                = 20,                            /* number of NBP table entries */
  341.     NBP_MAX_NAME_SIZE            = 16 + 10 + 2
  342. };
  343.  
  344.  
  345.  
  346. /* Command codes */
  347.  
  348. enum {
  349.     TCPCreate                    = 30,
  350.     TCPPassiveOpen                = 31,
  351.     TCPActiveOpen                = 32,
  352.     TCPSend                        = 34,
  353.     TCPNoCopyRcv                = 35,
  354.     TCPRcvBfrReturn                = 36,
  355.     TCPRcv                        = 37,
  356.     TCPClose                    = 38,
  357.     TCPAbort                    = 39,
  358.     TCPStatus                    = 40,
  359.     TCPExtendedStat                = 41,
  360.     TCPRelease                    = 42,
  361.     TCPGlobalInfo                = 43,
  362.     TCPCtlMax                    = 49
  363. };
  364.  
  365.  
  366. enum {
  367.     TCPClosing                    = 1,
  368.     TCPULPTimeout                = 2,
  369.     TCPTerminate                = 3,
  370.     TCPDataArrival                = 4,
  371.     TCPUrgent                    = 5,
  372.     TCPICMPReceived                = 6,
  373.     lastEvent                    = 32767
  374. };
  375.  
  376. typedef unsigned short                     TCPEventCode;
  377.  
  378. enum {
  379.     TCPRemoteAbort                = 2,
  380.     TCPNetworkFailure            = 3,
  381.     TCPSecPrecMismatch            = 4,
  382.     TCPULPTimeoutTerminate        = 5,
  383.     TCPULPAbort                    = 6,
  384.     TCPULPClose                    = 7,
  385.     TCPServiceError                = 8,
  386.     lastReason                    = 32767
  387. };
  388.  
  389. typedef unsigned short                     TCPTerminationReason;
  390. typedef CALLBACK_API( void , TCPNotifyProcPtr )(StreamPtr tcpStream, unsigned short eventCode, Ptr userDataPtr, unsigned short terminReason, ICMPReport *icmpMsg);
  391. typedef STACK_UPP_TYPE(TCPNotifyProcPtr)                         TCPNotifyUPP;
  392. typedef unsigned short                     tcp_port;
  393. /* ValidityFlags */
  394.  
  395. enum {
  396.     timeoutValue                = 0x80,
  397.     timeoutAction                = 0x40,
  398.     typeOfService                = 0x20,
  399.     precedence                    = 0x10
  400. };
  401.  
  402. /* TOSFlags */
  403.  
  404. enum {
  405.     lowDelay                    = 0x01,
  406.     throughPut                    = 0x02,
  407.     reliability                    = 0x04
  408. };
  409.  
  410. struct TCPCreatePB {
  411.     Ptr                             rcvBuff;
  412.     unsigned long                     rcvBuffLen;
  413.     TCPNotifyUPP                     notifyProc;
  414.     Ptr                             userDataPtr;
  415. };
  416. typedef struct TCPCreatePB TCPCreatePB;
  417.  
  418. struct TCPOpenPB {
  419.     SInt8                             ulpTimeoutValue;
  420.     SInt8                             ulpTimeoutAction;
  421.     SInt8                             validityFlags;
  422.     SInt8                             commandTimeoutValue;
  423.     ip_addr                         remoteHost;
  424.     tcp_port                         remotePort;
  425.     ip_addr                         localHost;
  426.     tcp_port                         localPort;
  427.     SInt8                             tosFlags;
  428.     SInt8                             precedence;
  429.     Boolean                         dontFrag;
  430.     SInt8                             timeToLive;
  431.     SInt8                             security;
  432.     SInt8                             optionCnt;
  433.     SInt8                             options[40];
  434.     Ptr                             userDataPtr;
  435. };
  436. typedef struct TCPOpenPB TCPOpenPB;
  437.  
  438.  
  439. struct TCPSendPB {
  440.     SInt8                             ulpTimeoutValue;
  441.     SInt8                             ulpTimeoutAction;
  442.     SInt8                             validityFlags;
  443.     Boolean                         pushFlag;
  444.     Boolean                         urgentFlag;
  445.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  446.     Ptr                             wdsPtr;
  447.     unsigned long                     sendFree;
  448.     unsigned short                     sendLength;
  449.     Ptr                             userDataPtr;
  450. };
  451. typedef struct TCPSendPB TCPSendPB;
  452.  
  453.  
  454. /* for receive and return rcv buff calls */
  455. /*   Note: the filler in the following structure is in a different location than */
  456. /*         that specified in the Programmer's Guide.  */
  457. struct TCPReceivePB {
  458.     SInt8                             commandTimeoutValue;
  459.     Boolean                         markFlag;
  460.     Boolean                         urgentFlag;
  461.     SInt8                             filler;                        /* Filler for proper byte alignment  */
  462.     Ptr                             rcvBuff;
  463.     unsigned short                     rcvBuffLen;
  464.     Ptr                             rdsPtr;
  465.     unsigned short                     rdsLength;
  466.     unsigned short                     secondTimeStamp;
  467.     Ptr                             userDataPtr;
  468. };
  469. typedef struct TCPReceivePB TCPReceivePB;
  470.  
  471.  
  472. struct TCPClosePB {
  473.     SInt8                             ulpTimeoutValue;
  474.     SInt8                             ulpTimeoutAction;
  475.     SInt8                             validityFlags;
  476.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  477.     Ptr                             userDataPtr;
  478. };
  479. typedef struct TCPClosePB TCPClosePB;
  480.  
  481. struct HistoBucket {
  482.     unsigned short                     value;
  483.     unsigned long                     counter;
  484. };
  485. typedef struct HistoBucket HistoBucket;
  486.  
  487.  
  488. enum {
  489.     NumOfHistoBuckets            = 7
  490. };
  491.  
  492. struct TCPConnectionStats {
  493.     unsigned long                     dataPktsRcvd;
  494.     unsigned long                     dataPktsSent;
  495.     unsigned long                     dataPktsResent;
  496.     unsigned long                     bytesRcvd;
  497.     unsigned long                     bytesRcvdDup;
  498.     unsigned long                     bytesRcvdPastWindow;
  499.     unsigned long                     bytesSent;
  500.     unsigned long                     bytesResent;
  501.     unsigned short                     numHistoBuckets;
  502.     HistoBucket                     sentSizeHisto[7];
  503.     unsigned short                     lastRTT;
  504.     unsigned short                     tmrSRTT;
  505.     unsigned short                     rttVariance;
  506.     unsigned short                     tmrRTO;
  507.     SInt8                             sendTries;
  508.     SInt8                             sourchQuenchRcvd;
  509. };
  510. typedef struct TCPConnectionStats TCPConnectionStats;
  511.  
  512. struct TCPStatusPB {
  513.     SInt8                             ulpTimeoutValue;
  514.     SInt8                             ulpTimeoutAction;
  515.     long                             unused;
  516.     ip_addr                         remoteHost;
  517.     tcp_port                         remotePort;
  518.     ip_addr                         localHost;
  519.     tcp_port                         localPort;
  520.     SInt8                             tosFlags;
  521.     SInt8                             precedence;
  522.     SInt8                             connectionState;
  523.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  524.     unsigned short                     sendWindow;
  525.     unsigned short                     rcvWindow;
  526.     unsigned short                     amtUnackedData;
  527.     unsigned short                     amtUnreadData;
  528.     Ptr                             securityLevelPtr;
  529.     unsigned long                     sendUnacked;
  530.     unsigned long                     sendNext;
  531.     unsigned long                     congestionWindow;
  532.     unsigned long                     rcvNext;
  533.     unsigned long                     srtt;
  534.     unsigned long                     lastRTT;
  535.     unsigned long                     sendMaxSegSize;
  536.     TCPConnectionStats *            connStatPtr;
  537.     Ptr                             userDataPtr;
  538. };
  539. typedef struct TCPStatusPB TCPStatusPB;
  540.  
  541. struct TCPAbortPB {
  542.     Ptr                             userDataPtr;
  543. };
  544. typedef struct TCPAbortPB TCPAbortPB;
  545.  
  546. struct TCPParam {
  547.     unsigned long                     tcpRtoA;
  548.     unsigned long                     tcpRtoMin;
  549.     unsigned long                     tcpRtoMax;
  550.     unsigned long                     tcpMaxSegSize;
  551.     unsigned long                     tcpMaxConn;
  552.     unsigned long                     tcpMaxWindow;
  553. };
  554. typedef struct TCPParam TCPParam;
  555.  
  556. struct TCPStats {
  557.     unsigned long                     tcpConnAttempts;
  558.     unsigned long                     tcpConnOpened;
  559.     unsigned long                     tcpConnAccepted;
  560.     unsigned long                     tcpConnClosed;
  561.     unsigned long                     tcpConnAborted;
  562.     unsigned long                     tcpOctetsIn;
  563.     unsigned long                     tcpOctetsOut;
  564.     unsigned long                     tcpOctetsInDup;
  565.     unsigned long                     tcpOctetsRetrans;
  566.     unsigned long                     tcpInputPkts;
  567.     unsigned long                     tcpOutputPkts;
  568.     unsigned long                     tcpDupPkts;
  569.     unsigned long                     tcpRetransPkts;
  570. };
  571. typedef struct TCPStats TCPStats;
  572.  
  573. typedef StreamPtr *                        StreamPPtr;
  574. struct TCPGlobalInfoPB {
  575.     TCPParam *                        tcpParamPtr;
  576.     TCPStats *                        tcpStatsPtr;
  577.     StreamPPtr                         tcpCDBTable[1];
  578.     Ptr                             userDataPtr;
  579.     unsigned short                     maxTCPConnections;
  580. };
  581. typedef struct TCPGlobalInfoPB TCPGlobalInfoPB;
  582.  
  583. typedef struct TCPiopb                     TCPiopb;
  584. typedef CALLBACK_API_C( void , TCPIOCompletionProcPtr )(TCPiopb *iopb);
  585. typedef STACK_UPP_TYPE(TCPIOCompletionProcPtr)                     TCPIOCompletionUPP;
  586. struct TCPiopb {
  587.     SInt8                             fill12[12];
  588.     TCPIOCompletionUPP                 ioCompletion;
  589.     short                             ioResult;
  590.     Ptr                             ioNamePtr;
  591.     short                             ioVRefNum;
  592.     short                             ioCRefNum;
  593.     short                             csCode;
  594.     StreamPtr                         tcpStream;
  595.     union {
  596.         TCPCreatePB                     create;
  597.         TCPOpenPB                         open;
  598.         TCPSendPB                         send;
  599.         TCPReceivePB                     receive;
  600.         TCPClosePB                         close;
  601.         TCPAbortPB                         abort;
  602.         TCPStatusPB                     status;
  603.         TCPGlobalInfoPB                 globalInfo;
  604.     }                                 csParam;
  605. };
  606.  
  607.  
  608. enum {
  609.     UDPCreate                    = 20,
  610.     UDPRead                        = 21,
  611.     UDPBfrReturn                = 22,
  612.     UDPWrite                    = 23,
  613.     UDPRelease                    = 24,
  614.     UDPMaxMTUSize                = 25,
  615.     UDPStatus                    = 26,
  616.     UDPMultiCreate                = 27,
  617.     UDPMultiSend                = 28,
  618.     UDPMultiRead                = 29,
  619.     UDPCtlMax                    = 29
  620. };
  621.  
  622.  
  623. enum {
  624.     UDPDataArrival                = 1,
  625.     UDPICMPReceived                = 2,
  626.     lastUDPEvent                = 32767
  627. };
  628.  
  629. typedef unsigned short                     UDPEventCode;
  630. typedef CALLBACK_API( void , UDPNotifyProcPtr )(StreamPtr udpStream, unsigned short eventCode, Ptr userDataPtr, ICMPReport *icmpMsg);
  631. typedef STACK_UPP_TYPE(UDPNotifyProcPtr)                         UDPNotifyUPP;
  632. typedef unsigned short                     udp_port;
  633. /* for create and release calls */
  634. struct UDPCreatePB {
  635.     Ptr                             rcvBuff;
  636.     unsigned long                     rcvBuffLen;
  637.     UDPNotifyUPP                     notifyProc;
  638.     unsigned short                     localPort;
  639.     Ptr                             userDataPtr;
  640.     udp_port                         endingPort;
  641. };
  642. typedef struct UDPCreatePB UDPCreatePB;
  643.  
  644. struct UDPSendPB {
  645.     unsigned short                     reserved;
  646.     ip_addr                         remoteHost;
  647.     udp_port                         remotePort;
  648.     Ptr                             wdsPtr;
  649.     Boolean                         checkSum;
  650.     SInt8                             filler;                        /* Filler for proper byte alignment     */
  651.     unsigned short                     sendLength;
  652.     Ptr                             userDataPtr;
  653.     udp_port                         localPort;
  654. };
  655. typedef struct UDPSendPB UDPSendPB;
  656.  
  657. /* for receive and buffer return calls */
  658. struct UDPReceivePB {
  659.     unsigned short                     timeOut;
  660.     ip_addr                         remoteHost;
  661.     udp_port                         remotePort;
  662.     Ptr                             rcvBuff;
  663.     unsigned short                     rcvBuffLen;
  664.     unsigned short                     secondTimeStamp;
  665.     Ptr                             userDataPtr;
  666.     ip_addr                         destHost;                    /* only for use with multi rcv */
  667.     udp_port                         destPort;                    /* only for use with multi rcv */
  668. };
  669. typedef struct UDPReceivePB UDPReceivePB;
  670.  
  671. struct UDPMTUPB {
  672.     unsigned short                     mtuSize;
  673.     ip_addr                         remoteHost;
  674.     Ptr                             userDataPtr;
  675. };
  676. typedef struct UDPMTUPB UDPMTUPB;
  677.  
  678. typedef struct UDPiopb                     UDPiopb;
  679. typedef CALLBACK_API_C( void , UDPIOCompletionProcPtr )(UDPiopb *iopb);
  680. typedef STACK_UPP_TYPE(UDPIOCompletionProcPtr)                     UDPIOCompletionUPP;
  681. struct UDPiopb {
  682.     SInt8                             fill12[12];
  683.     UDPIOCompletionUPP                 ioCompletion;
  684.     short                             ioResult;
  685.     Ptr                             ioNamePtr;
  686.     short                             ioVRefNum;
  687.     short                             ioCRefNum;
  688.     short                             csCode;
  689.     StreamPtr                         udpStream;
  690.     union {
  691.         UDPCreatePB                     create;
  692.         UDPSendPB                         send;
  693.         UDPReceivePB                     receive;
  694.         UDPMTUPB                         mtu;
  695.     }                                 csParam;
  696. };
  697.  
  698. enum { uppGetIPIOCompletionProcInfo = 0x000000C1 };             /* no_return_value Func(4_bytes) */
  699. enum { uppIPIOCompletionProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  700. enum { uppICMPEchoNotifyProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  701. enum { uppTCPNotifyProcInfo = 0x0000EEC0 };                     /* pascal no_return_value Func(4_bytes, 2_bytes, 4_bytes, 2_bytes, 4_bytes) */
  702. enum { uppTCPIOCompletionProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  703. enum { uppUDPNotifyProcInfo = 0x00003EC0 };                     /* pascal no_return_value Func(4_bytes, 2_bytes, 4_bytes, 4_bytes) */
  704. enum { uppUDPIOCompletionProcInfo = 0x000000C1 };                 /* no_return_value Func(4_bytes) */
  705. #define NewGetIPIOCompletionProc(userRoutine)                     (GetIPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, GetCurrentArchitecture())
  706. #define NewIPIOCompletionProc(userRoutine)                         (IPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppIPIOCompletionProcInfo, GetCurrentArchitecture())
  707. #define NewICMPEchoNotifyProc(userRoutine)                         (ICMPEchoNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, GetCurrentArchitecture())
  708. #define NewTCPNotifyProc(userRoutine)                             (TCPNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPNotifyProcInfo, GetCurrentArchitecture())
  709. #define NewTCPIOCompletionProc(userRoutine)                     (TCPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, GetCurrentArchitecture())
  710. #define NewUDPNotifyProc(userRoutine)                             (UDPNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPNotifyProcInfo, GetCurrentArchitecture())
  711. #define NewUDPIOCompletionProc(userRoutine)                     (UDPIOCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, GetCurrentArchitecture())
  712. #define CallGetIPIOCompletionProc(userRoutine, iopb)             CALL_ONE_PARAMETER_UPP((userRoutine), uppGetIPIOCompletionProcInfo, (iopb))
  713. #define CallIPIOCompletionProc(userRoutine, iopb)                 CALL_ONE_PARAMETER_UPP((userRoutine), uppIPIOCompletionProcInfo, (iopb))
  714. #define CallICMPEchoNotifyProc(userRoutine, iopb)                 CALL_ONE_PARAMETER_UPP((userRoutine), uppICMPEchoNotifyProcInfo, (iopb))
  715. #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg)  CALL_FIVE_PARAMETER_UPP((userRoutine), uppTCPNotifyProcInfo, (tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
  716. #define CallTCPIOCompletionProc(userRoutine, iopb)                 CALL_ONE_PARAMETER_UPP((userRoutine), uppTCPIOCompletionProcInfo, (iopb))
  717. #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppUDPNotifyProcInfo, (udpStream), (eventCode), (userDataPtr), (icmpMsg))
  718. #define CallUDPIOCompletionProc(userRoutine, iopb)                 CALL_ONE_PARAMETER_UPP((userRoutine), uppUDPIOCompletionProcInfo, (iopb))
  719.  
  720.  
  721. #if PRAGMA_STRUCT_ALIGN
  722.     #pragma options align=reset
  723. #elif PRAGMA_STRUCT_PACKPUSH
  724.     #pragma pack(pop)
  725. #elif PRAGMA_STRUCT_PACK
  726.     #pragma pack()
  727. #endif
  728.  
  729. #ifdef PRAGMA_IMPORT_OFF
  730. #pragma import off
  731. #elif PRAGMA_IMPORT
  732. #pragma import reset
  733. #endif
  734.  
  735. #ifdef __cplusplus
  736. }
  737. #endif
  738.  
  739. #endif /* __MACTCP__ */
  740.  
  741.